<template>
  <view class="video-generating-container">
    <view class="main-content">
      <view class="generating-card">
        <view class="loading-section">
          <view class="loading-icon">
            <view class="spinner"></view>
          </view>
          <text class="title">视频生成中</text>
          <text class="subtitle">你的艺术作品正在生成中，可能需要一段时间，可以先返回</text>
          <text class="status-text">{{ statusText }}</text>
        </view>
        
        <view class="action-section">
          <button class="return-btn" @click="goToHome">返回创作中心</button>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue'

let pollInterval = null
const statusText = ref('排队中...')

onMounted(() => {
  // 页面加载时的逻辑
  console.log('视频生成页面已加载')
  
  // 获取传递的参数
  const pages = getCurrentPages()
  const current = pages[pages.length - 1]
  const { options } = current
  
  console.log('视频生成页面参数:', options)
  
  // 模拟状态更新
  setTimeout(() => {
    statusText.value = '处理中...'
  }, 3000)
  
  setTimeout(() => {
    statusText.value = '即将完成...'
  }, 8000)
})

onUnmounted(() => {
  // 清理轮询定时器
  if (pollInterval) {
    clearInterval(pollInterval)
  }
})

function goToHome() {
  uni.reLaunch({
    url: '/pages/index/index'
  })
}
</script>

<style lang="scss">
.video-generating-container {
  min-height: 100vh;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-content {
  width: 100%;
  padding: 20px;
}

.generating-card {
  background: #333333;
  border-radius: 20px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(212, 175, 55, 0.15);
}

.loading-section {
  margin-bottom: 30px;
}

.loading-icon {
  margin-bottom: 20px;
  display: flex;
  justify-content: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(212, 175, 55, 0.2);
  border-top: 4px solid #d4af37;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.title {
  display: block;
  font-size: 24px;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 10px;
}

.subtitle {
  display: block;
  font-size: 16px;
  color: #a0826d;
  line-height: 1.5;
  margin-bottom: 10px;
}

.status-text {
  display: block;
  font-size: 14px;
  color: #d4af37;
  font-weight: 600;
  margin-top: 10px;
}

.action-section {
  margin-top: 20px;
}

.return-btn {
  background: linear-gradient(135deg, #ff0050, #ff4081);
  color: #ffffff;
  border: none;
  border-radius: 25px;
  padding: 15px 40px;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  
  &:active {
    transform: translateY(2px);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
  }
}
</style>
